import VueRouter from 'vue-router'

import routes from './routes'

export default () => {
  return new VueRouter({
    routes,
    mode: 'history', // 开启history模式开发时webpack-dev-server要配置historyApiFallback选项
    base: '/base/', // 配置base选项需要配置webpack的output.publicPath选项
    linkActiveClass: 'active-link',
    linkExactActiveClass: 'exact-active-link',
    scrollBehavior (to, from, savedPosition) {
      if (savedPosition) {
        return savedPosition
      } else {
        return { x: 0, y: 0 }
      }
    },
    fallback: true // 如果浏览器不支持history会变成hash
    // parseQuery(query){},
    // stringifyQuery(obj){}
  })
}
